package com.jac.alapores.rest;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import com.jac.alapores.domain.User;
import com.jac.alapores.manager.AlaporesManager;

@Path("/rest/user")
public class UserController 
{
	private final static AlaporesManager ALAPORES_MANAGER = new AlaporesManager();
	
	@POST
	@Consumes({MediaType.APPLICATION_JSON})    
	@Path("/post")
	public String createUser(User user)
	{
		ALAPORES_MANAGER.addUser(user);
		return "success";
	}
	
	@GET
	@Produces({MediaType.APPLICATION_JSON})
	@Path("/login/{userID}")
	public User fetchUser(@PathParam("userID") String userID)
	{
		return ALAPORES_MANAGER.fetchCreateUser(userID);
	}		
}
